using System;
using IO=System.IO;
using System.Collections.Generic;
using System.Text;

using EastBancTech.DSL.FileSystemDefinition.Native;

namespace EastBancTech.DSL.FileSystemDefinition
{
    public partial class FileModel
    {
        internal string GetShortNameValue()
        {
            if (String.IsNullOrEmpty(this.Name))
                return "";
          
          
            return Native.FileSystemInterop.GetShortFileName(this.Store, Name);
        }

        internal string GetPathValue()
        {
            if (String.IsNullOrEmpty(this.Name))
                return "";

            return IO.Path.Combine(this.DirectoryModel.Path, this.Name);
        }

        public virtual String GetUniqueName()
        {
            return String.Format("{0}::{1}", FileSystem.Name, this.Path);
        }

        public FileSystemModel FileSystem
        {
            get 
            {
                DirectoryModel dir = this.DirectoryModel;

                while (dir.Parent != null)
                    dir = dir.Parent;

                return dir.FileSystem;
            }
        }
    }

    public partial class AssemblyFileModel
    {
        public override string GetUniqueName()
        {
            return String.Format(@"{0}::{1}", FileSystem.Name, IO.Path.Combine(IO.Path.GetDirectoryName(this.Path), this.AssemblyName));
        }
    }
}
